<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>iOS 隐私清单生成器</title>
    <link rel="stylesheet" href="styles.css">
</head>
<body>
    <header class="vibrant-header">
        <h1>iOS 隐私清单生成器</h1>
        <p class="tagline">轻松生成你的 PrivacyInfo.xcprivacy 文件</p>
        <p class="deadline">从2024年5月1日起，苹果要求所有使用特定API的应用必须声明其使用情况</p>
    </header>

    <main class="container">
        <section class="generator-section">
            <div class="input-group">
                <label for="app-name">应用名称</label>
                <input type="text" id="app-name" placeholder="输入你的应用名称">
            </div>

            <section class="api-category-section">
                <h3>API 类别</h3>
                <p class="section-desc">选择你的应用使用的API类别</p>
                <div class="api-options">
                    <div class="api-option">
                        <input type="checkbox" id="file-timestamp" name="api-category">
                        <label for="file-timestamp">文件时间戳 APIs</label>
                        <div class="tooltip">用于显示文件时间戳信息</div>
                    </div>
                    <div class="api-reasons" data-for="file-timestamp" style="display: none;">
                        <div class="reason-options">
                            <div class="reason-option">
                                <input type="checkbox" id="DDA9.1" name="api-reason">
                                <label for="DDA9.1">
                                    <code>DDA9.1</code>
                                    <span class="reason-text">
                                        <span class="zh">向设备用户显示文件时间戳</span>
                                        <span class="en">Display file timestamps to the person using the device</span>
                                    </span>
                                </label>
                            </div>
                            <div class="reason-option">
                                <input type="checkbox" id="C617.1" name="api-reason">
                                <label for="C617.1">
                                    <code>C617.1</code>
                                    <span class="reason-text">
                                        <span class="zh">访问应用容器内的文件时间戳和元数据</span>
                                        <span class="en">Access timestamps and metadata of files inside the app container</span>
                                    </span>
                                </label>
                            </div>
                            <div class="reason-option">
                                <input type="checkbox" id="3B52.1" name="api-reason">
                                <label for="3B52.1">
                                    <code>3B52.1</code>
                                    <span class="reason-text">
                                        <span class="zh">访问用户授权的文件时间戳和元数据</span>
                                        <span class="en">Access timestamps and metadata of user granted files</span>
                                    </span>
                                </label>
                            </div>
                        </div>
                    </div>
                    <div class="api-option">
                        <input type="checkbox" id="system-boot" name="api-category">
                        <label for="system-boot">系统启动时间 APIs</label>
                        <div class="tooltip">访问系统启动时间信息</div>
                    </div>
                    <div class="api-reasons" data-for="system-boot" style="display: none;">
                        <div class="reason-options">
                            <div class="reason-option">
                                <input type="checkbox" id="CA92.1-boot" name="api-reason">
                                <label for="CA92.1-boot">
                                    <code>CA92.1</code>
                                    <span class="reason-text">
                                        <span class="zh">访问系统启动时间用于基本功能</span>
                                        <span class="en">Access system boot time for essential functionality</span>
                                    </span>
                                </label>
                            </div>
                        </div>
                    </div>
                    <div class="api-option">
                        <input type="checkbox" id="disk-space" name="api-category">
                        <label for="disk-space">磁盘空间 APIs</label>
                        <div class="tooltip">获取设备存储空间信息</div>
                    </div>
                    <div class="api-reasons" data-for="disk-space" style="display: none;">
                        <div class="reason-options">
                            <div class="reason-option">
                                <input type="checkbox" id="CA92.1-disk" name="api-reason">
                                <label for="CA92.1-disk">
                                    <code>CA92.1</code>
                                    <span class="reason-text">
                                        <span class="zh">访问磁盘空间信息用于基本功能</span>
                                        <span class="en">Access disk space information for essential functionality</span>
                                    </span>
                                </label>
                            </div>
                        </div>
                    </div>
                    <div class="api-option">
                        <input type="checkbox" id="keyboard" name="api-category">
                        <label for="keyboard">活动键盘 APIs</label>
                        <div class="tooltip">访问键盘输入相关信息</div>
                    </div>
                    <div class="api-reasons" data-for="keyboard" style="display: none;">
                        <div class="reason-options">
                            <div class="reason-option">
                                <input type="checkbox" id="CA92.1-keyboard" name="api-reason">
                                <label for="CA92.1-keyboard">
                                    <code>CA92.1</code>
                                    <span class="reason-text">
                                        <span class="zh">访问键盘状态用于基本功能</span>
                                        <span class="en">Access keyboard state for essential functionality</span>
                                    </span>
                                </label>
                            </div>
                        </div>
                    </div>
                    <div class="api-option">
                        <input type="checkbox" id="user-defaults" name="api-category">
                        <label for="user-defaults">用户默认设置 APIs</label>
                        <div class="tooltip">访问应用的用户默认设置</div>
                    </div>
                    <div class="api-reasons" data-for="user-defaults" style="display: none;">
                        <div class="reason-options">
                            <div class="reason-option">
                                <input type="checkbox" id="CA92.1-defaults" name="api-reason">
                                <label for="CA92.1-defaults">
                                    <code>CA92.1</code>
                                    <span class="reason-text">
                                        <span class="zh">访问用户默认设置用于基本功能</span>
                                        <span class="en">Access user defaults for essential functionality</span>
                                    </span>
                                </label>
                            </div>
                        </div>
                    </div>
                </div>
            </section>

            <section class="data-collection-section">
                <h3>数据收集类型</h3>
                <p class="section-desc">选择你的应用收集的数据类型</p>
                <div class="data-collection">
                    <div class="data-collection-container">
                        <div class="data-options-container">
                            <div class="data-targets-section">
                                <h4>数据使用目标</h4>
                                <div class="target-options">
                                    <label class="target-option">
                                        <input type="checkbox" name="linked" value="NSPrivacyCollectedDataTypeLinked">
                                        <span>与身份关联</span>
                                    </label>
                                    <label class="target-option">
                                        <input type="checkbox" name="tracking" value="NSPrivacyCollectedDataTypeTracking">
                                        <span>收集用于跟踪</span>
                                    </label>
                                </div>
                            </div>

                            <div class="data-purposes-section">
                                <h4>收集目的</h4>
                                <div class="purpose-options">
                                    <label class="purpose-option">
                                        <input type="checkbox" name="third-party-ads" value="NSPrivacyCollectedDataTypePurposeThirdPartyAdvertising">
                                        <span>第三方广告</span>
                                    </label>
                                    <label class="purpose-option">
                                        <input type="checkbox" name="developer-ads" value="NSPrivacyCollectedDataTypePurposeDeveloperAdvertising">
                                        <span>开发者广告</span>
                                    </label>
                                    <label class="purpose-option">
                                        <input type="checkbox" name="analytics" value="NSPrivacyCollectedDataTypePurposeAnalytics">
                                        <span>数据分析</span>
                                    </label>
                                    <label class="purpose-option">
                                        <input type="checkbox" name="personalization" value="NSPrivacyCollectedDataTypePurposeProductPersonalization">
                                        <span>个性化</span>
                                    </label>
                                    <label class="purpose-option">
                                        <input type="checkbox" name="app-functionality" value="NSPrivacyCollectedDataTypePurposeAppFunctionality">
                                        <span>应用功能</span>
                                    </label>
                                    <label class="purpose-option">
                                        <input type="checkbox" name="other" value="NSPrivacyCollectedDataTypePurposeOther">
                                        <span>其他</span>
                                    </label>
                                </div>
                            </div>

                            <div class="data-type-selector">
                                <select id="data-type-select" class="data-type-dropdown">
                                    <option value="">-- 选择数据类型 --</option>
                                    <optgroup label="用户信息">
                                        <option value="NSPrivacyCollectedDataTypeName">姓名</option>
                                        <option value="NSPrivacyCollectedDataTypeEmailAddress">电子邮件</option>
                                        <option value="NSPrivacyCollectedDataTypePhoneNumber">电话号码</option>
                                        <option value="NSPrivacyCollectedDataTypePhysicalAddress">物理地址</option>
                                        <option value="NSPrivacyCollectedDataTypeOtherUserContactInfo">其他联系信息</option>
                                    </optgroup>
                                    <optgroup label="健康与健身">
                                        <option value="NSPrivacyCollectedDataTypeHealth">健康数据</option>
                                        <option value="NSPrivacyCollectedDataTypeFitness">健身数据</option>
                                    </optgroup>
                                    <optgroup label="财务信息">
                                        <option value="NSPrivacyCollectedDataTypePaymentInfo">支付信息</option>
                                        <option value="NSPrivacyCollectedDataTypeCreditInfo">信用信息</option>
                                        <option value="NSPrivacyCollectedDataTypeOtherFinancialInfo">其他财务信息</option>
                                    </optgroup>
                                    <optgroup label="位置信息">
                                        <option value="NSPrivacyCollectedDataTypePreciseLocation">精确位置</option>
                                        <option value="NSPrivacyCollectedDataTypeCoarseLocation">大致位置</option>
                                    </optgroup>
                                    <optgroup label="敏感信息">
                                        <option value="NSPrivacyCollectedDataTypeSensitiveInfo">敏感信息</option>
                                    </optgroup>
                                    <optgroup label="用户内容">
                                        <option value="NSPrivacyCollectedDataTypeEmailsOrTextMessages">邮件或短信</option>
                                        <option value="NSPrivacyCollectedDataTypePhotosOrVideos">照片和视频</option>
                                        <option value="NSPrivacyCollectedDataTypeAudioData">音频数据</option>
                                        <option value="NSPrivacyCollectedDataTypeGameplayContent">游戏内容</option>
                                        <option value="NSPrivacyCollectedDataTypeCustomerSupport">客户支持</option>
                                        <option value="NSPrivacyCollectedDataTypeOtherUserContent">其他用户内容</option>
                                    </optgroup>
                                    <optgroup label="浏览历史">
                                        <option value="NSPrivacyCollectedDataTypeBrowsingHistory">浏览历史</option>
                                    </optgroup>
                                    <optgroup label="搜索历史">
                                        <option value="NSPrivacyCollectedDataTypeSearchHistory">搜索历史</option>
                                    </optgroup>
                                    <optgroup label="标识符">
                                        <option value="NSPrivacyCollectedDataTypeUserID">用户ID</option>
                                        <option value="NSPrivacyCollectedDataTypeDeviceID">设备ID</option>
                                    </optgroup>
                                    <optgroup label="购买记录">
                                        <option value="NSPrivacyCollectedDataTypePurchaseHistory">购买历史</option>
                                    </optgroup>
                                    <optgroup label="使用数据">
                                        <option value="NSPrivacyCollectedDataTypeProductInteraction">产品交互</option>
                                        <option value="NSPrivacyCollectedDataTypeAdvertisingData">广告数据</option>
                                        <option value="NSPrivacyCollectedDataTypeOtherUsageData">其他使用数据</option>
                                    </optgroup>
                                    <optgroup label="诊断数据">
                                        <option value="NSPrivacyCollectedDataTypeCrashData">崩溃数据</option>
                                        <option value="NSPrivacyCollectedDataTypePerformanceData">性能数据</option>
                                        <option value="NSPrivacyCollectedDataTypeOtherDiagnosticData">其他诊断数据</option>
                                    </optgroup>
                                </select>
                                <button class="add-data-type-btn">添加数据类型</button>
                            </div>
                        </div>

                        <div class="selected-items-summary">
                            <h4>已添加的数据收集项</h4>
                            <div class="selected-items-grid"></div>
                        </div>
                    </div>

                    <div class="data-type-details" style="display: none;">
                        <div class="data-type-header">
                            <h4 class="data-type-name"></h4>
                            <button class="remove-data-type-btn">移除</button>
                        </div>
                        
                        <div class="data-type-options">
                            <div class="data-type-targets">
                                <h5>数据使用目标</h5>
                                <div class="target-options">
                                    <label class="target-option">
                                        <input type="checkbox" name="linked" value="NSPrivacyCollectedDataTypeLinked">
                                        <span>与身份关联</span>
                                    </label>
                                    <label class="target-option">
                                        <input type="checkbox" name="tracking" value="NSPrivacyCollectedDataTypeTracking">
                                        <span>收集用于跟踪</span>
                                    </label>
                                </div>
                            </div>

                            <div class="data-type-purposes">
                                <h5>收集目的</h5>
                                <div class="purpose-options">
                                    <label class="purpose-option">
                                        <input type="checkbox" name="third-party-ads" value="NSPrivacyCollectedDataTypePurposeThirdPartyAdvertising">
                                        <span>第三方广告</span>
                                    </label>
                                    <label class="purpose-option">
                                        <input type="checkbox" name="developer-ads" value="NSPrivacyCollectedDataTypePurposeDeveloperAdvertising">
                                        <span>开发者广告</span>
                                    </label>
                                    <label class="purpose-option">
                                        <input type="checkbox" name="analytics" value="NSPrivacyCollectedDataTypePurposeAnalytics">
                                        <span>数据分析</span>
                                    </label>
                                    <label class="purpose-option">
                                        <input type="checkbox" name="personalization" value="NSPrivacyCollectedDataTypePurposeProductPersonalization">
                                        <span>个性化</span>
                                    </label>
                                    <label class="purpose-option">
                                        <input type="checkbox" name="app-functionality" value="NSPrivacyCollectedDataTypePurposeAppFunctionality">
                                        <span>应用功能</span>
                                    </label>
                                    <label class="purpose-option">
                                        <input type="checkbox" name="other" value="NSPrivacyCollectedDataTypePurposeOther">
                                        <span>其他</span>
                                    </label>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </section>

            <section class="tracking-section">
                <h3>数据追踪</h3>
                <p class="section-desc">配置应用的数据追踪选项</p>
                <div class="tracking-option">
                    <input type="checkbox" id="tracking-enabled" name="tracking">
                    <label for="tracking-enabled">启用数据追踪</label>
                    <div class="tooltip">需要实现 App Tracking Transparency (ATT) 框架</div>
                </div>

                <div class="tracking-purposes" style="display: none;">
                    <h4>追踪目的</h4>
                    <div class="purpose-options">
                        <div class="purpose-option">
                            <input type="checkbox" id="third-party-ads" name="tracking-purpose">
                            <label for="third-party-ads">第三方广告</label>
                        </div>
                        <div class="purpose-option">
                            <input type="checkbox" id="developer-ads" name="tracking-purpose">
                            <label for="developer-ads">开发者广告</label>
                        </div>
                        <div class="purpose-option">
                            <input type="checkbox" id="analytics" name="tracking-purpose">
                            <label for="analytics">数据分析</label>
                        </div>
                        <div class="purpose-option">
                            <input type="checkbox" id="personalization" name="tracking-purpose">
                            <label for="personalization">个性化</label>
                        </div>
                    </div>
                </div>

                <div class="tracking-domains" style="display: none;">
                    <h4>追踪域名</h4>
                    <div class="domain-input-group">
                        <input type="text" id="tracking-domain" placeholder="example.com">
                        <button class="add-domain-btn">添加</button>
                    </div>
                    <ul class="domain-list"></ul>
                </div>
            </section>

            <section class="att-section">
                <h3>ATT 配置</h3>
                <p class="section-desc">配置 App Tracking Transparency 提示信息</p>
                <div class="input-group">
                    <label for="att-description">追踪权限描述</label>
                    <textarea id="att-description" placeholder="请描述为什么需要追踪用户数据，例如：'我们需要访问广告标识符来为您提供个性化广告体验'"></textarea>
                </div>
            </section>

            <button class="generate-btn">生成隐私清单</button>
        </section>

        <section class="output-section">
            <h2>生成的隐私清单</h2>
            <div class="manifest-output">
                <pre id="manifest-content">选择上方的选项来生成隐私清单...</pre>
            </div>
            <div class="action-buttons">
                <button class="copy-btn">复制到剪贴板</button>
                <button class="download-btn">下载文件</button>
            </div>
        </section>
    </main>

    <footer class="vibrant-footer">
        <p>基于 Apple 隐私清单规范构建</p>
        <p class="footer-note">从 iOS 14.5 起，所有应用都必须实现 App Tracking Transparency 框架才能访问广告标识符</p>
    </footer>

    <script src="script.js"></script>
</body>
</html>